const debounce = {
  timerId: null,
  install(Vue) {
    Vue.prototype.$debounce = (ms) => {
      if (debounce.timerId) {
        clearTimeout(debounce.timerId);
      }
      return new Promise((resolve, reject) => {
        debounce.timerId = setTimeout(resolve, ms);
      });
    };
  },
};

export default debounce;
